/**
 * Created by 1 on 2021/12/4.
 */
public class TestMain {
    public static void main(String[] args) {
        LRUCacheManager<Object> manager = new LRUCacheManager<>(100,100,100);

        String key = "test";

        Object o = manager.getCache(key);
        if (o == null) {
            try {
                manager.lockInterruptiblyByKey(key);
                // todo get o
                o = new Object();

                manager.putCache(key,o,3600 * 1000L);

                manager.unlockAllByKey(key);
            } catch (InterruptedException e) {
                System.out.println("o put , lock cancel");
                o = manager.getCache(key);
            } finally {
                manager.unlockByKey(key);
            }
        }

        System.out.println(o);
    }
}
